package com.dqx.utils;

import android.graphics.SurfaceTexture;
import android.hardware.Camera;

/**
 * 摄像头功能接口
 */
public interface ICamera {

    //打开相机
    boolean open(int cameraId);

    //设置配置
    void setConfig(Config config);

    //开始预览
    boolean preview();

    //切换摄像头
    boolean switchTo(int cameraId);

    //拍照
    void takePhoto(TakePhotoCallback callback);

    //关闭相机
    boolean close();

    //设置预览处理控件
    void setPreviewTexture(SurfaceTexture texture);

    //获得预览大小
    Camera.Size getPreviewSize();

    //获得图片大小
    Camera.Size getPictureSize();

    //设置预览回调
    void setOnPreviewFrameCallback(PreviewFrameCallback callback);

    //自定义配置
    class Config {
        //宽高比
        float rate;
        //预览宽度
        int previewWidth;
        //预览高度
        int pictureWidth;
    }

    interface TakePhotoCallback {
        void onTakePhoto(byte[] bytes, int width, int height);
    }

    interface PreviewFrameCallback {
        void onPreviewFrame(byte[] bytes, int width, int height);
    }
}
